﻿using System;
using System.Windows.Navigation;
using SC2TV.ViewModel;

namespace SC2TV
{
    public partial class PrivateMessageReaderPage
    {
        string messageUrl;
        public PrivateMessageReaderPage()
        {
            InitializeComponent();
        }

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            
            NavigationContext.QueryString.TryGetValue("messageUrl", out messageUrl);
            if (String.IsNullOrEmpty(messageUrl))
            {
                NavigationService.GoBack();
                return;
            }

            var vm = DataContext as PrivateMessageReaderViewModel;
            await vm.Load(messageUrl);
        }

        private void ReplyClick(object sender, EventArgs e)
        {
            var vm = DataContext as PrivateMessageReaderViewModel;
            //NavigationService.Navigate(new Uri("/PrivateMessageWriterPage.xaml?formID=privatemsg_form_reply&token=" + vm.Token + "&requestUrl=" + messageUrl + "&userName=" + vm.User, UriKind.Relative));
        }
    }
}